function ajax(method, url, args, callback) {
	var req = false,
		cb = callback || null;

	req = XMLHttpRequest  ? new XMLHttpRequest : new ActiveXObject('Msxml2.XMLHTTP');
	
	var params = buildHttpQuery(args);
	switch (method) {
		case 'get':
		case 'GET':
			req.open(method, url + params, false);
			params = null;
			break;
		case 'POST':
		case 'post':
			req.open(method, url, false);
			req.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
			params = params.substr(1);
			break;
	}
	
	req.onreadystatechange = function() {
		if (this.readyState == 4) {
			switch (this.status) {
				case 200:
				case 304:
					if (cb) cb(this.responseText);
					break;
			}
		}
	};
	
	req.send(params);
}

function buildHttpQuery(str) {
	var args = '';
	if (typeof str === 'string') {
		args = str[0] == '?' ? str : '?' + str;
	}
	else if (Object.prototype.toString.call(str) === '[object Object]') {
		var arr = [];
		for (arg in str) {
			arr.push(encodeURIComponent(arg) + '=' + encodeURIComponent(str[arg]));
		}
		args = '?' + arr.join('&');
	}
	
	return args;
}